import time

file = open('file1.txt', 'a+', buffering=1)
file.seek(0, 0)
count = len(file.readlines()) + 1
while True:
    file.write(str(count) + " " + time.ctime() + '\n')
    count += 1
    # file.flush()
    time.sleep(2)
file.close()
